"""
初始化脚本扫描账号数据库
"""
import json
from com.db.database import DatabaseManager

def init_script_scan_account_table(db: DatabaseManager):
    """
    初始化脚本扫描账号表
    :param db: 数据库管理器实例
    """
    # 定义表结构
    columns = {
        'id': 'INTEGER PRIMARY KEY',
        'script_id': 'INTEGER NOT NULL',
        'scan_account_id': 'INTEGER NOT NULL'
    }
    
    # 创建表
    db.create_table("script_scan_account", columns)

def import_script_scan_account_data():
    """
    导入script-scan-account_data.json数据到数据库
    """
    db = DatabaseManager()
    
    # 初始化表
    init_script_scan_account_table(db)
    
    # 读取JSON数据
    with open('com/db/uudata/script-scan-account_data.json', 'r', encoding='utf-8') as f:
        data = json.load(f)
    
    # 导入数据
    for item in data:
        db.insert("script_scan_account", item)
    
    print("Script-scan-account数据导入完成!")

if __name__ == "__main__":
    import_script_scan_account_data()
